<?php echo $this->render($this->includeDir . '/toolbar.php');?>
<?php echo $this->flashMessage();?>
<?php 
	$arrParam = $this->arrParam;
	/*===============================================
	 * Start - Tạo các phần tử cho Form
	 *===============================================*/	
	$config = new Zendvn_Controller_Config ( array ('module' => $arrParam['module'], 'fileConfig' => 'slider.ini' ) );
	$avatarConfig = $config->getConfig ( 'slider' );
	$thumbUrl = $avatarConfig['thumbUrl'];
	$removeLink = $this->currentController . '/remove-pic/type/picture/id/' .$this->Item ['id'];
	//	'fileExt'     : '*.jpg;*.gif;*.png',
	$fileExt = $avatarConfig['extension'];
	if(count($fileExt) > 0){
		$strFileExt = '';
		foreach ($fileExt as $val){
			$strFileExt .= '*.' . $val . ';';
		}
	}
	
	$arrType = array(
					'image' => 'Image', 'flash' => 'Flash'
					);
	$type_upload	= $this->formSelect('type_upload', $this->Item['type_upload'], array('class'=>'width-150 floatLeft' ), $arrType);

	$name 		= $this->formText('name',$this->Item['name'],array('class'=>'width-300 bg-green2 floatLeft' ));
	//$name 		.= $this->cmsError('name');
	$link 		= $this->formText('link',$this->Item['link'],array('class'=>'width-300 bg-green2 floatLeft' ));
	
	$description = $this->formTextarea('description', Zendvn_Filter_Filter::filterContent($this->Item['description'], 'filter'), array('class'=>'floatLeft', 'rows' => 10 ));
	
	$picture	= $this->formFile('picture',array('class'=>'floatLeft' ));
	if($this->arrParam['action'] == 'edit'){
		$config = new Zendvn_Controller_Config(array('module'=>$arrParam['module'],
												'fileConfig'=>'slider.ini'));
	 	// Start - Lấy hình ảnh của avatar	 	
	 	$pictureConfig = $config->getConfig('slider');
		$current_picture = '<div id="load-content-picture" class="clr width-150 center">';
		if(!empty($this->Item['picture'])){
			$pictureUrl = $pictureConfig['thumbUrl'] . '/' . $this->Item['picture'];
			$removeLink = $this->url(array('action'=>'remove-pic','type'=>'picture','file'=>$this->Item['picture']));
			$current_picture .= '<br>' . $this->cmsImage('picture',$pictureUrl,array('width'=>'75px'))
							. '<br><a  class="remove" href="javascript:loadPage(\'div#load-content-picture\',\'' . $removeLink . '\')">remove</a>';
		}
		$current_picture .= $this->formHidden('current_picture',$this->Item['picture'])
						. '</div>';
		$picture .=	$current_picture;		
	}
	$ordering	= $this->formText('ordering',$this->Item['ordering'],array('class'=>'width-100 floatLeft'));
	$options 	= array('inactive'=>$this->translate('Inactive'),'active'=>$this->translate('Active'));	
	$status 	= $this->formSelect('status',$this->Item['status'],array('class'=>'width-150'),$options);
	/*=======================================================
	 * Start - Tạo Tooltip cho các phần từ input trong form
	 *=======================================================*/	
	$formHelp = '';
	$config = new Zendvn_Controller_Config(array('module'=>$arrParam['module'],
												'fileConfig'=>'slider.ini',
												'section'=>'tooltip'));
	$arrTooltip = $config->getConfig('slider');
	if(count($arrTooltip)>0){
		foreach ($arrTooltip as $key => $val){
			$formHelp  .= $this->cmsFormHelp('.form-table #' . $key, $this->translate($val));	
		}
	}
	/*=======================================================
	 * Start - Hiển thị các thông báo error của Form 
	 *=======================================================*/	
	 if(count($this->errors)>0){	
	 	foreach ($this->errors as $key => $val){	 		
	 		$$key .= $this->cmsError($key,$val);	
	 		$selector = '.form-table #' . $key . '-error';
	 		$options = array('type'=>'error','name'=>'#' .$key);
	 		$formHelp  .= $this->cmsFormHelp($selector, $this->translate($val),null,$options);
	 	}
	 }
	$arrRow = array(
						array('label'=>$this->translate('Name'),'input'=>$name),
						array('label'=>$this->translate('Type Upload'),'input'=>$type_upload),								
						array('label'=>$this->translate('Picture'),'input'=>$picture),								
 						array('label'=>$this->translate('Link'),'input'=>$link),								
// 						array('label'=>$this->translate('Description'),'input'=>$description),								
						array('label'=>$this->translate('Status'),'input'=>$status),
						array('label'=>$this->translate('Ordering'),'input'=>$ordering),
					 );
	$tdForm = $this->partialLoop('row.php',$arrRow);
?>
<script type="text/javascript">
	$(document).ready(function() {
		<?php echo $formHelp;?>
	});
</script>
<div id="element-box">
	<div class="m">
		<div class="form-table">
            <fieldset class="admin-fieldset">
                <legend class="admin-legend"><?php echo $this->translate('Form Detail')?></legend>
            	<table width="100%" border="0">
                	<?php echo $tdForm;?>
                </table>
                <div class="clr"></div>
			</fieldset>   
        </div>
            <div class="clr"></div>
	</div>
</div>
